-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-125880: Fix exit codes in PyREPL #125890
base: main
Are you sure you want to change the base?
Conversation
Eclips4
commented
Oct 23, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: Exit codes are lost in the REPL #125880
@@ -101,6 +101,7 @@ pymain_err_print(int *exitcode_p) | |||
int exitcode; | |||
if (_Py_HandleSystemExit(&exitcode)) { | |||
*exitcode_p = exitcode; | |||
Py_Exit(exitcode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed in order to match behavior of PyRUn_AnyFileExFlags
(which the old REPL called an still calls if PYTHON_BASIC_REPL=1
) which somewhere calls handle_system_exit
(Python/pythonrun.c::L632)
) which handles SystemExit
and calls Py_Exit
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case this path doesn't return as this calls PyFinalize_Ex
and then exit()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As well as previous approach with PyRun_AnyFileExFlags
, so, is this a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow what you mean. Could you clarify ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not being clear!
I mean, the previous approach with PyRun_AnyFileExFlags
contains path with handle_system_exit
which is also didn't return as it calls PyFinalizeEx
and then exit()
.